package cn.blunce.ArrayTest;

import java.util.Random;

/**
 * Created by Experiment on 2016/3/31 0031.
 */
public class MyArrays {
    private Random random = new Random();

    private int pRand(int mod) {
        return Math.abs(random.nextInt()) % mod + 1;
    }

    public void MonArrayTest() {
        int[] a;
        a = new int[pRand(20)];
        System.out.println("length of a = " + a.length);
        for (int i = 0; i < a.length; i++)
            System.out.println("a[" + i + "] = " + a[i]);
    }

    public void MultiArrayTest() {
        int[][] a1 = {
                {1, 2, 3},
                {4, 5, 6}
        };
        for (int i = 0; i < a1.length; i++)
            for (int j = 0; j < a1[i].length; j++)
                System.out.println("a1[" + i + "][" + j +
                        "] = " + a1[i][j]);
    }

    public static void main(String[] args) {
        new MyArrays().MonArrayTest();
        new MyArrays().MultiArrayTest();
    }
}
